﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Administration;
using System.Configuration;

namespace SharePoint911.SPAXO
{
    internal static class SpaxoGlobal
    {
        private const string CONFIG_SETTINGS_STORE_NAME = "SP911.SpaxoConfig";

        /// <summary>
        /// Creates settings
        /// </summary>
        internal static ConfigSettings CreateSettings(SPWebApplication webApplicaiton)
        {
            return new ConfigSettings(CONFIG_SETTINGS_STORE_NAME, webApplicaiton);
        }

        /// <summary>
        /// Gets settings
        /// </summary>
        internal static ConfigSettings GetSettings(SPWebApplication webApplicaiton)
        {
            return webApplicaiton.GetChild<ConfigSettings>(CONFIG_SETTINGS_STORE_NAME);
        }

        /// <summary>
        /// Validate Settings
        /// </summary>
        internal static bool ValidateSettings(ConfigSettings settings)
        {
            if (settings == null ||
                String.IsNullOrEmpty(settings.InjectionOption))
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
